<template>
  <Card title="管理员设置">
    <Card :bordered="false">
      <Select :clearable="true" v-model="model1" style="width:200px" @on-change="query">
        <Option v-for="item in cityList" :value="item.cuTownId" :key="item.cuTownId">{{ item.cuTownName }}</Option>
      </Select>
    </Card>
    <Table border stripe ref="selection" size="small" :columns="columns" :data="nowData">
<!--      <template slot-scope="{ row, index }" slot="action">-->
<!--        <Modal-->
<!--          v-model="modal1"-->
<!--          title="提示"-->
<!--          @on-ok="okDel"-->
<!--          @on-cancel="cancel">-->
<!--          <p>确定要删除此新闻吗?删除后将不能恢复</p>-->
<!--        </Modal>-->
<!--      </template>-->
    </Table>
    <Page :total="dataCount" :page-size="bo.size" @on-change="changepage" @on-page-size-change="_nowPageSize"
          show-total show-sizer show-elevator/>
  </Card>
</template>

<script>
export default {
  name: 'admin',
  data(){
    return{
      model1:null,
      cityList:[],
      dataCount:0,
      columns:[
        {
          title: '序号',
          key: 'cuAdminId'
        },
        {
          title: '用户名',
          key: 'cuAdminUsername'
        },
        {
          title: '所属场馆',
          key: 'cuAdminPwd'
        },
        {
          title: '是否为最高管理员',
          key: 'cuParentId',
          render:(h,params)=>{

            let gender = params.row.cuParentId
            if(gender == 0){
              gender = '否'
            }else if(gender == 1){
              gender = '是'
            }
            return h('span',gender)
          },
        },
        {
          title: '操作',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      nowData:[],
      bo:{
        size:10,
        current:1,
        cuOnlyId:null,
      },
    }
  },methods:{
    _nowPageSize(index){
      // 实时获取当前需要显示的条数
      this.bo.size = index
    },
    changepage(index){
      this.bo.current = index;
      this.query()
    },
    query(){
      this.bo.cuOnlyId = this.model1;
      this.$axios_supermall.post("/admin/queryPage",this.bo).then(resp =>{
      if (resp.data.code == 0){
        let data = resp.data.data
        this.nowData = data.records
        this.bo.current = data.current
        this.bo.size = data.size
        this.dataCount = data.total
      }
      });

    },
    queryList(){
      this.$axios_supermall.post("/town/queryList").then(resp=>{
        if (resp.data.code == 0){
          this.cityList = resp.data.data;
        }
      })
    },
  },mounted() {
    this.queryList();
    this.query();
    console.log(this.cityList)
  }
}
</script>

<style scoped>

</style>
